
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[spShippingStatusReportGetTotalSalesOrder]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [spShippingStatusReportGetTotalSalesOrder]
GO

CREATE PROCEDURE spShippingStatusReportGetTotalSalesOrder
	@OfficeID int,	
	@poType int,	
	@SalesOrder int	
AS

SELECT COUNT(*) FROM [ShippingStatusReport] 
WHERE OfficeID=@OfficeID
AND (@SalesOrder = -1 OR SalesOrder = @SalesORder)
AND ((@poType = 0 AND CompletedDate IS NULL) 
	OR (@poType = 1 AND CompletedDate IS NOT NULL))


GO

	
  